import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  build: {
    // cssCodeSplit: false  // only one css file , including async chunk's css
    // sourcemap: 'hidden'
    // sourcemap: true,
    // manifest: true,
    lib: {
      entry: './src/directives/ripple.ts',
      name: 'RippleLite',
      // formats: ['es'], // esm
      // formats: ['umd'], 
      formats: ['cjs'], // commonjs
      fileName: 'ripple-lite'
    }
  },
  server: {
    host: true,
    port: 3030
  },
  preview: {
    host: true, // all address , same as 0.0.0.0
    port: 3031,
  }
})
